cmake_minimum_required(VERSION 2.8)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER /opt/atk-dlrv1126-toolchain/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER /opt/atk-dlrv1126-toolchain/bin/arm-linux-gnueabihf-g++)

set(CMAKE_SYSROOT /opt/atk-dlrv1126-toolchain/arm-buildroot-linux-gnueabihf/sysroot)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(CMAKE_CXX_STANDARD 14)

project(testUsb C CXX)

aux_source_directory(. SRC)
aux_source_directory(./3rd/utils/ SRC_UTILS)

include_directories(.)
include_directories(${PROJECT_SOURCE_DIR}/3rd/utils)
include_directories(${PROJECT_SOURCE_DIR}/3rd/include)
include_directories(${PROJECT_SOURCE_DIR}/3rd/include/libfyaml)
include_directories(${PROJECT_SOURCE_DIR}/3rd/include/mosquitto)

find_library(LIB_yaml libfyaml.a ${PROJECT_SOURCE_DIR}/3rd/lib)
find_library(LIB_mqtt mosquitto ${PROJECT_SOURCE_DIR}/3rd/lib/libfyaml)
find_library(LIB_mqtt mosquitto ${PROJECT_SOURCE_DIR}/3rd/lib/mosquitto)

find_file(CJSON cJSON.c ${PROJECT_SOURCE_DIR}/3rd/utils)

# mosquitto v2.0.8
link_directories(${PROJECT_SOURCE_DIR}/3rd/lib/)
link_directories(${PROJECT_SOURCE_DIR}/3rd/lib/libfyaml)
link_directories(${PROJECT_SOURCE_DIR}/3rd/lib/mosquitto)

add_definitions(-DDEV_MODBUS_USB_VERSION="v0.0.1")

message("source file is ${SRC}")
message("project source dir is ${PROJECT_SOURCE_DIR}")

set(TARGET sys_manager)

add_executable(${TARGET} ${SRC} ${SRC_UTILS})

target_link_libraries(${TARGET} pthread fyaml mosquitto)
